package com.ly.web.controller.erp;

import com.ly.heart.domain.dto.KingProfitLossDto;
import com.ly.heart.service.IKingProfitLossService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ly.common.annotation.Log;
import com.ly.common.core.controller.BaseController;
import com.ly.common.core.domain.AjaxResult;
import com.ly.common.enums.BusinessType;
import com.ly.heart.domain.KingProfitLossEntity;

import javax.annotation.Resource;

/**
 * 盘盈单/盘亏单基础信息Controller
 * @author wutao
 * @date 2024-07-23
 */
@Api (value = "KingProfitLoss", tags = "盘盈单/盘亏单基础信息")
@RestController
@RequestMapping ("/heart/KingProfitLoss")
public class KingProfitLossController extends BaseController {

    @Resource
    private IKingProfitLossService kingProfitLossEntityService;

    /**
     * 查询盘盈单/盘亏单基础信息列表
     */
    @PreAuthorize ("@ss.hasPermi('heart:KingProfitLoss:list')")
    @GetMapping ("/list")
    @ApiOperation ("查询盘盈单/盘亏单基础信息列表")
    public AjaxResult list (KingProfitLossEntity kingProfitLossEntity) {
        AjaxResult ajaxResult = kingProfitLossEntityService.selectKingProfitLossEntityList ( kingProfitLossEntity );
        return ajaxResult;
    }

    /**
     * 获取盘盈单/盘亏单基础信息详细信息
     */
    @PreAuthorize ("@ss.hasPermi('heart:KingProfitLoss:query')")
    @GetMapping (value = "/{id}")
    @ApiOperation ("获取盘盈单/盘亏单基础信息详细信息")
    public AjaxResult getInfo (@PathVariable ("id") String id) {
        return AjaxResult.success ( kingProfitLossEntityService.selectKingProfitLossEntityById ( id ) );
    }

    /**
     * 新增盘盈单/盘亏单基础信息
     */
    @PreAuthorize ("@ss.hasPermi('heart:KingProfitLoss:add')")
    @Log (title = "盘盈单/盘亏单基础信息", businessType = BusinessType.INSERT)
    @PostMapping("draft")
    @ApiOperation ("新增盘盈单/盘亏单基础信息")
    public AjaxResult draft (@RequestBody KingProfitLossDto kingProfitLossDto) {
        return kingProfitLossEntityService.draft ( kingProfitLossDto );
    }

    @PreAuthorize ("@ss.hasPermi('heart:KingProfitLoss:add')")
    @Log (title = "盘盈单/盘亏单基础信息", businessType = BusinessType.INSERT)
    @PostMapping("submit")
    @ApiOperation ("新增盘盈单/盘亏单基础信息")
    public AjaxResult submit (@RequestBody KingProfitLossEntity kingProfitLossEntity) {
        return kingProfitLossEntityService.submit ( kingProfitLossEntity );
    }

    /**
     * 修改盘盈单/盘亏单基础信息
     */
    @PreAuthorize ("@ss.hasPermi('heart:KingProfitLoss:edit')")
    @Log (title = "盘盈单/盘亏单基础信息", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation ("修改盘盈单/盘亏单基础信息")
    public AjaxResult edit (@RequestBody KingProfitLossDto kingProfitLossDto) {
        return kingProfitLossEntityService.updateKingProfitLossEntity ( kingProfitLossDto );
    }

    /**
     * 删除盘盈单/盘亏单基础信息
     */
    @PreAuthorize ("@ss.hasPermi('heart:KingProfitLoss:remove')")
    @Log (title = "盘盈单/盘亏单基础信息", businessType = BusinessType.DELETE)
    @DeleteMapping ("/{ids}")
    @ApiOperation ("删除盘盈单/盘亏单基础信息")
    public AjaxResult remove (@PathVariable String[] ids) {
        return kingProfitLossEntityService.deleteKingProfitLossEntityByIds ( ids );
    }
}
